import tinify
if __name__ == '__main__':

    try:
        API_KEY = input('请输入key:')
        print(API_KEY)
        tinify.key = API_KEY
        tinify.validate()
        source = tinify.from_url("http://xxxxx")
        source.to_file("xxxxx")
        compressions_this_month = tinify.compression_count
        print(compressions_this_month)
    except tinify.Error as e:
        print(e)
        # Validation of API key failed.
        pass
    pass
